#include <algorithm>
#include <stack>
using namespace std;

class CQueue {
   public:
    stack<int> left;
    stack<int> right;

    CQueue() {
    }

    void appendTail(int value) {
        right.push(value);
    }

    int deleteHead() {
        if (left.empty()) {
            if (right.empty()) {
                return -1;
            } else {
                while (!right.empty()) {
                    left.push(right.top());
                    right.pop();
                }
            }
        }

        int res = left.top();
        left.pop();
        return res;
    }
};

/**
 * Your CQueue object will be instantiated and called as such:
 * CQueue* obj = new CQueue();
 * obj->appendTail(value);
 * int param_2 = obj->deleteHead();
 */